#!/bin/bash

set -e

# select table_name, col_name from information_schema.ins_columns where table_type = 'SUPER_TABLE' and col_type = 'TIMESTAMP' and db_name = 'iot_ts' and table_name='properties_g_modbus' and col_name in ('ts','_ts');

# 测试动态查询超级表的主键列

user="root"
pwd="taosdata"
db="iot_ts"

# ------------------------------------------ 封装的函数 ------------------------------------------

function execute_sql(){
    local sql=$1
    taos -u "$user" "-p$pwd" -s "$sql"
}

# cp iot_ts_20231010_data_device_log_virtual_e_modbus_virtual_201000029.csv 111111111122222222223333333333444444444455555555556666666666123456.csv

part1="/mnt/sdc/opt/ems-archive/data/import/iot_ts/iot_ts_20231010/"
part2="111111111122222222223333333333444444444455555555556666666666777.csv"

echo "part1.length: ${#part1}"
echo "part2.length: ${#part2}"

file_path="${part1}${part2}"
echo "file_path.length: ${#file_path}"

#file_path="/mnt/sdc/opt/ems-archive/data/import/iot_ts/iot_ts_20231010/iot_ts_20231010_data_device_log_virtual_e_modbus_virtual_201000029.csv"
import_long_name_file="use test_iot_ts; insert into device_log_virtual_e_modbus_virtual_201000029 file '${file_path}'";
execute_sql "$import_long_name_file"

# 结论：导入文件最大长度为 127 
